package com.mx102.kosmos;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL11;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g3d.decals.Decal;
import com.badlogic.gdx.graphics.g3d.decals.DecalBatch;

public class Sprite {

	private Texture texture;

	private float x,y,z;
	private Decal sprite;
	private DecalBatch decalBatch;
	
	
	public Sprite(String texName,float scale) {
		
		texture = new Texture(Gdx.files.internal(texName), true);
		texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		sprite = Decal.newDecal(10, 10, new TextureRegion(texture), true);
		sprite.setScale(scale);
		
		
		decalBatch = new DecalBatch();
		
	}
	
	public void render(GL11 gl,Camera oCam) {

		sprite.lookAt(oCam.position.cpy(), oCam.up.cpy().nor());
		sprite.setPosition(x, z, y);
		decalBatch.add(sprite);
		decalBatch.flush();
	}
	
	public void setPosition(float x,float y,float z) {
		this.x=x;
		this.y=y;		
		this.z=z;	
	}
	
	public float getY() {
		return this.y;
	}
	
	public void move(float dx,float dy) {
		this.x=x+dx;
		this.y=y+dy;
	}
	
}
